package com.jzy.stock.kufangkuqu.mapper;

import com.jzy.stock.kufangkuqu.model.BusinessAttributeVo;
import com.jzy.stock.kufangkuqu.model.ListVo;
import com.jzy.stock.kufangkuqu.model.SelectVo;
import com.jzy.stock.kufangkuqu.model.WareHouseVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by JZZK on 2022/7/11.
 */
@Mapper
public interface KuFangKuQuMapper {
    List<ListVo> queryPage(SelectVo selectVo);

    int queryCount(SelectVo selectVo);

    @Select("select * from reservoir_area where id=#{id}")
    ListVo queryById(Integer id);

    @Update("update reservoir_area set status=#{status},updateName=#{updateName},updateTime=#{updateTime} where id =#{id}")
    void updateStatus(ListVo listVo1);

    @Select("select * from reservoir_area where code=#{code} and wareHouseCode=#{wareHouseCode}")
    ListVo queryByCode(@Param("code") String code, @Param("wareHouseCode") String wareHouseCode);

    @Select("select * from reservoir_area where name=#{name} and wareHouseCode=#{wareHouseCode}")
    ListVo queryByName(@Param("name") String name, @Param("wareHouseCode") String wareHouseCode);

    void addVo(ListVo listVo);

    @Update("update reservoir_area set name=#{name},remark=#{remark},vipStorageSection=#{vipStorageSection},warehouseManagement=#{warehouseManagement},wmsIntegrate=#{wmsIntegrate},updateTime=#{updateTime},updateName=#{updateName} where id=#{id}")
    void update(ListVo listVo2);

    @Select("select id,name,code,remark  from stockroom")
    List<WareHouseVo> queryWareHouse();

    @Select("select id,name  from kuqushuxing")
    List<BusinessAttributeVo> queryBusinessAttribute();

    void addVo2(ListVo listVo2);

    @Select("select s.code wareHouseCode,s.name  wareHouseName,s.remark wareHouseRemark,r.* from reservoir_area r LEFT JOIN stockroom s ON r.wareHouseCode=s.code   where r.id=#{id}")
    ListVo queryStorageSectionById(Integer id);

    /*void update2(ListVo listVo2);*/

    @Delete("delete from kuqushuxingzjb where storageSectionCode=#{code}")
    void delete(String code);

    @Select("select k1.name name,k.shuxingId id from kuqushuxingzjb k LEFT JOIN kuqushuxing k1 ON k.shuxingId=k1.id  where k.storageSectionCode=#{code}")
    List<BusinessAttributeVo> queryByCode1(String code);
}
